#include "qserver.h"

//add by dimon, 2024-03-18 15:125
#include "qtcpthread.h"
#include <QtDebug>

QServer::QServer(QObject *parent) : QTcpServer(parent)
{

}

void QServer::incomingConnection(qintptr sockDescriptor)
{
    qDebug() << "incomming Connect in QServer.cpp" << endl ;

    ///启动新线程以响应TCP连接请求
    QTcpThread *thread = new QTcpThread(sockDescriptor,this);

    //
    //sockDescriptor.moveToThread(thread);
    //关联 信号-槽
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));


    //'QTcpThread'的父基类为QThread，所以可以执行QThread::和start()函数
    qDebug() << "QTcpThread() is to start";
    qDebug() << "QTcpThread() is to start,  parnet Current thread is: " << QThread::currentThread();
    qDebug() << "QTcpThread() is to start";
    thread->start();
}
